<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8" />
<title>无标题文档</title>
</head>

<script>
function getWindowSize() {
    var client = {
        x:0,
        y:0
    };
 
    if(typeof document.compatMode != 'undefined' && document.compatMode == 'CSS1Compat') {
        client.x = document.documentElement.clientWidth;
        client.y = document.documentElement.clientHeight;
    } else if(typeof document.body != 'undefined' && (document.body.scrollLeft || document.body.scrollTop)) {
        client.x = document.body.clientWidth;
        client.y = document.body.clientHeight;
    }
 
    return client;
}

function getsize(){
	var size = getWindowSize();
	document.getElementById("width").value = size.x;
	document.getElementById("height").value = size.y;
}
</script>

<body onresize="getsize()">
width:<input type="text" id="width" /><br />
height:<input type="text" id="height" />
</body>
</html>
